﻿#pragma once

#include <QWidget>

class QLabel;
class QLineEdit;

// 这个限定数字
class SvgPropInput : public QWidget
{
	Q_OBJECT
public:
	SvgPropInput(const QString& text, double max = INFINITE, double min = 0, QWidget* parent = nullptr);

	void SetInc(double inc);
	double Value() const;

public slots:
	void SetValue(double value);

signals:
	void ValueChanged(double);

protected:
	void mousePressEvent(QMouseEvent* event) override;
	void mouseDoubleClickEvent(QMouseEvent* event) override;
	void mouseMoveEvent(QMouseEvent* event) override;
	void mouseReleaseEvent(QMouseEvent* event) override;
	void focusOutEvent(QFocusEvent* event) override;

private slots:
	void _EditFinished();

private:
	QLabel* m_label;
	QLineEdit* m_edit;
	QPointF m_lastPoint{ NAN, NAN };
	double m_max = INFINITE;
	double m_min = 0;
	double m_inc = 1;
	double m_value = 0;
};